// store/index.js
import { createStore } from 'vuex';

export default createStore({
  state: {
    userInfo: null,
    token: null
  },
  mutations: {
    updateUserAndToken(state, payload) {
      state.userInfo = payload.userInfo;
      state.token = payload.token;
      uni.setStorageSync('_user_info', payload.userInfo);
      uni.setStorageSync('_token', payload.token);
    }
  },
  actions: {
    // 可以在这里添加异步逻辑
  },
  getters: {
    isAuthenticated: (state) => !!state.token
  }
});